<template>
  <!-- 收藏的专辑 -->
  <div class="mtop-20">
    <el-card>
      <div class="subalbum-head">
        <div>
          <span class="font-bold">收藏的专辑</span>
          <span class="fon-12" style="color: #cfcfcf">({{ count }})</span>
        </div>
        <div class="detail-search">
          <el-input
            placeholder="搜索收藏专辑"
            clearable
            suffix-icon="el-icon-search"
            v-model="key"
          ></el-input>
        </div>
      </div>
      <div class="mtop-20">
        <InfoList :list="subalbumList" @clickitem="toAblumDetail">
            <template #img="{item}">
                <img :src="item.picUrl" class="mleft-10">
            </template>
            <template #title="{item}">
                {{item.name}}
            </template>
            <template #item1="{item}">
                {{item.artists[0].name}}
            </template>
            <template #item2="{item}">
                {{item.size}}首
            </template>
        </InfoList>
      </div>
    </el-card>
  </div>
</template>

<script>
import { getSubAlbum } from "@/api/request";
import InfoList from "@/components/list/infoList.vue";
export default {
  components: { InfoList },
  data() {
    return {
      list: [],
      key: "",
      count: 0,
      offset: 0,
    };
  },
  computed:{
    subalbumList(){
        return this.list.filter((item) => item.name.match(this.key));
    }
  },
  created() {
    this.getAblumList();
  },
  methods: {
    async getAblumList() {
      const { data: res } = await getSubAlbum();
      if (res.code !== 200) return;
      this.list = res.data;
      this.count = res.count;
    },
    toAblumDetail(row){
        this.$router.push('/albumdetail/' + row.id)
    }
  },
};
</script>

<style lang="less" scoped>
.subalbum-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
img{
    width: 80px;
    height: 80px;
    border-radius: 5px;
}
</style>